<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover"><title>PyQt密码管理系统 | Xing's Blog</title><meta name="author" content="xing"><meta name="copyright" content="xing"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="PyQt密码管理系统">
<meta property="og:type" content="article">
<meta property="og:title" content="PyQt密码管理系统">
<meta property="og:url" content="https://veryxing.github.io/article/32b656da.html">
<meta property="og:site_name" content="Xing&#39;s Blog">
<meta property="og:description" content="PyQt密码管理系统">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-2.png">
<meta property="article:published_time" content="2024-10-20T14:36:18.000Z">
<meta property="article:modified_time" content="2024-10-31T15:24:22.710Z">
<meta property="article:author" content="xing">
<meta property="article:tag" content="PyQt">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-2.png"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://veryxing.github.io/article/32b656da.html"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css"><script>
    (() => {
      
    const saveToLocal = {
      set: (key, value, ttl) => {
        if (!ttl) return
        const expiry = Date.now() + ttl * 86400000
        localStorage.setItem(key, JSON.stringify({ value, expiry }))
      },
      get: key => {
        const itemStr = localStorage.getItem(key)
        if (!itemStr) return undefined
        const { value, expiry } = JSON.parse(itemStr)
        if (Date.now() > expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return value
      }
    }

    window.btf = {
      saveToLocal,
      getScript: (url, attr = {}) => new Promise((resolve, reject) => {
        const script = document.createElement('script')
        script.src = url
        script.async = true
        Object.entries(attr).forEach(([key, val]) => script.setAttribute(key, val))
        script.onload = script.onreadystatechange = () => {
          if (!script.readyState || /loaded|complete/.test(script.readyState)) resolve()
        }
        script.onerror = reject
        document.head.appendChild(script)
      }),
      getCSS: (url, id) => new Promise((resolve, reject) => {
        const link = document.createElement('link')
        link.rel = 'stylesheet'
        link.href = url
        if (id) link.id = id
        link.onload = link.onreadystatechange = () => {
          if (!link.readyState || /loaded|complete/.test(link.readyState)) resolve()
        }
        link.onerror = reject
        document.head.appendChild(link)
      }),
      addGlobalFn: (key, fn, name = false, parent = window) => {
        if (!true && key.startsWith('pjax')) return
        const globalFn = parent.globalFn || {}
        globalFn[key] = globalFn[key] || {}
        if (name && globalFn[key][name]) return
        globalFn[key][name || Object.keys(globalFn[key]).length] = fn
        parent.globalFn = globalFn
      }
    }
  
      
      const activateDarkMode = () => {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      const activateLightMode = () => {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }

      btf.activateDarkMode = activateDarkMode
      btf.activateLightMode = activateLightMode

      const theme = saveToLocal.get('theme')
    
          theme === 'dark' ? activateDarkMode() : theme === 'light' ? activateLightMode() : null
        
      
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        document.documentElement.classList.toggle('hide-aside', asideStatus === 'hide')
      }
    
      
    const detectApple = () => {
      if (/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)) {
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
  
    })()
  </script><script>const GLOBAL_CONFIG = {
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.json","preload":false,"top_n_per_article":1,"unescape":false,"languages":{"hits_empty":"未找到符合您查询的内容：${query}","hits_stats":"共找到 ${hits} 篇文章"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlight.js","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false,"highlightFullpage":false,"highlightMacStyle":true},
  copy: {
    success: '复制成功',
    error: '复制失败',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  dateSuffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'null',
  Snackbar: undefined,
  infinitegrid: {
    js: 'https://cdn.jsdelivr.net/npm/@egjs/infinitegrid/dist/infinitegrid.min.js',
    buttonText: '加载更多'
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: false,
  percent: {
    toc: true,
    rightside: false,
  },
  autoDarkmode: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'PyQt密码管理系统',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: false,
  postUpdate: '2024-10-31 23:24:22'
}</script><meta name="generator" content="Hexo 7.3.0"><link rel="alternate" href="/atom.xml" title="Xing's Blog" type="application/atom+xml">
</head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "/images/2.gif" data-lazy-src="/img/butterfly-icon.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">59</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">55</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/gallery/"><i class="fa-fw fas fa-folder-open"></i><span> 图库</span></a></div><div class="menus_item"><a class="site-page" href="/shuoshuo/"><i class="fa-fw fas fa-folder-open"></i><span> 说说</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url(https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-2.png);"><nav id="nav"><span id="blog-info"><a class="nav-site-title" href="/"><span class="site-name">Xing's Blog</span></a><a class="nav-page-title" href="/"><span class="site-name">PyQt密码管理系统</span></a></span><div id="menus"><div id="search-button"><span class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></span></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/gallery/"><i class="fa-fw fas fa-folder-open"></i><span> 图库</span></a></div><div class="menus_item"><a class="site-page" href="/shuoshuo/"><i class="fa-fw fas fa-folder-open"></i><span> 说说</span></a></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><span class="site-page"><i class="fas fa-bars fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">PyQt密码管理系统</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-10-20T14:36:18.000Z" title="发表于 2024-10-20 22:36:18">2024-10-20</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-10-31T15:24:22.710Z" title="更新于 2024-10-31 23:24:22">2024-10-31</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/PyQt/">PyQt</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">浏览量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><span id="more"></span>

<p>主程序登录界面：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Form implementation generated from reading ui file &#x27;wb.ui&#x27;</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Created by: PyQt5 UI code generator 5.10.1</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># WARNING! All changes made in this file will be lost!</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> PyQt5 <span class="keyword">import</span> QtCore, QtGui, QtWidgets</span><br><span class="line"><span class="keyword">from</span> PyQt5.QtCore <span class="keyword">import</span> pyqtSignal</span><br><span class="line"><span class="keyword">import</span> sign_in</span><br><span class="line"><span class="keyword">import</span> sys</span><br><span class="line"><span class="keyword">import</span> connectData</span><br><span class="line"><span class="keyword">import</span> password_screen</span><br><span class="line"><span class="keyword">import</span> background_rc</span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Ui_MainWindow</span>(<span class="title class_ inherited__">object</span>):</span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">setupUi</span>(<span class="params">self, MainWindow</span>):</span><br><span class="line">        MainWindow.setObjectName(<span class="string">&quot;MainWindow&quot;</span>)</span><br><span class="line">        MainWindow.resize(<span class="number">400</span>, <span class="number">300</span>)</span><br><span class="line">        <span class="variable language_">self</span>.MainWindow = MainWindow</span><br><span class="line">        icon = QtGui.QIcon()</span><br><span class="line">        icon.addPixmap(QtGui.QPixmap(<span class="string">&quot;:/icon/wb.ico&quot;</span>), QtGui.QIcon.Normal, QtGui.QIcon.Off)</span><br><span class="line">        MainWindow.setWindowIcon(icon)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.SQL = connectData.sql()</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.centralwidget = QtWidgets.QWidget(MainWindow)</span><br><span class="line">        <span class="variable language_">self</span>.centralwidget.setObjectName(<span class="string">&quot;centralwidget&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout = QtWidgets.QHBoxLayout(<span class="variable language_">self</span>.centralwidget)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.setObjectName(<span class="string">&quot;horizontalLayout&quot;</span>)</span><br><span class="line">        spacerItem = QtWidgets.QSpacerItem(<span class="number">40</span>, <span class="number">20</span>, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addItem(spacerItem)</span><br><span class="line">        <span class="variable language_">self</span>.widget = QtWidgets.QWidget(<span class="variable language_">self</span>.centralwidget)</span><br><span class="line">        <span class="variable language_">self</span>.widget.setObjectName(<span class="string">&quot;widget&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout_2 = QtWidgets.QVBoxLayout(<span class="variable language_">self</span>.widget)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout_2.setObjectName(<span class="string">&quot;verticalLayout_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout = QtWidgets.QVBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.setObjectName(<span class="string">&quot;verticalLayout&quot;</span>)</span><br><span class="line">        spacerItem1 = QtWidgets.QSpacerItem(<span class="number">20</span>, <span class="number">40</span>, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addItem(spacerItem1)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2 = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.setObjectName(<span class="string">&quot;horizontalLayout_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.label = QtWidgets.QLabel(<span class="variable language_">self</span>.widget)</span><br><span class="line">        <span class="variable language_">self</span>.label.setObjectName(<span class="string">&quot;label&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.addWidget(<span class="variable language_">self</span>.label)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit = QtWidgets.QLineEdit(<span class="variable language_">self</span>.widget)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit.setObjectName(<span class="string">&quot;lineEdit&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.addWidget(<span class="variable language_">self</span>.lineEdit)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout_2)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3 = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.setObjectName(<span class="string">&quot;horizontalLayout_3&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.label_2 = QtWidgets.QLabel(<span class="variable language_">self</span>.widget)</span><br><span class="line">        <span class="variable language_">self</span>.label_2.setObjectName(<span class="string">&quot;label_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.addWidget(<span class="variable language_">self</span>.label_2)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_2 = QtWidgets.QLineEdit(<span class="variable language_">self</span>.widget)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_2.setObjectName(<span class="string">&quot;lineEdit_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.addWidget(<span class="variable language_">self</span>.lineEdit_2)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout_3)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4 = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4.setObjectName(<span class="string">&quot;horizontalLayout_4&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton = QtWidgets.QPushButton(<span class="variable language_">self</span>.widget)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setObjectName(<span class="string">&quot;pushButton&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4.addWidget(<span class="variable language_">self</span>.pushButton, <span class="number">0</span>, QtCore.Qt.AlignHCenter)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2 = QtWidgets.QPushButton(<span class="variable language_">self</span>.widget)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.setObjectName(<span class="string">&quot;pushButton_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4.addWidget(<span class="variable language_">self</span>.pushButton_2, <span class="number">0</span>, QtCore.Qt.AlignHCenter)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout_4)</span><br><span class="line">        spacerItem2 = QtWidgets.QSpacerItem(<span class="number">20</span>, <span class="number">40</span>, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addItem(spacerItem2)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout_2.addLayout(<span class="variable language_">self</span>.verticalLayout)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addWidget(<span class="variable language_">self</span>.widget)</span><br><span class="line">        spacerItem3 = QtWidgets.QSpacerItem(<span class="number">40</span>, <span class="number">20</span>, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addItem(spacerItem3)</span><br><span class="line">        MainWindow.setCentralWidget(<span class="variable language_">self</span>.centralwidget)</span><br><span class="line">        <span class="variable language_">self</span>.statusbar = QtWidgets.QStatusBar(MainWindow)</span><br><span class="line">        <span class="variable language_">self</span>.statusbar.setObjectName(<span class="string">&quot;statusbar&quot;</span>)</span><br><span class="line">        MainWindow.setStatusBar(<span class="variable language_">self</span>.statusbar)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.retranslateUi(MainWindow)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.clicked.connect(<span class="variable language_">self</span>.show_sign_in_windows)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.clicked.connect(<span class="variable language_">self</span>.show_logon_windows)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_2.returnPressed.connect(<span class="variable language_">self</span>.show_logon_windows)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_2.setEchoMode(QtWidgets.QLineEdit.Password)</span><br><span class="line"></span><br><span class="line">        QtCore.QMetaObject.connectSlotsByName(MainWindow)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">show_sign_in_windows</span>(<span class="params">self</span>):</span><br><span class="line">        <span class="variable language_">self</span>.Dialog = QtWidgets.QDialog()</span><br><span class="line">        <span class="variable language_">self</span>.ui2 = sign_in.Ui_Dialog()</span><br><span class="line">        <span class="variable language_">self</span>.ui2.closeWindow.connect(<span class="variable language_">self</span>.MainWindow_show)</span><br><span class="line">        <span class="variable language_">self</span>.ui2.setupUi(<span class="variable language_">self</span>.Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.Dialog.show()</span><br><span class="line">        MainWindow.hide()</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">show_logon_windows</span>(<span class="params">self</span>):</span><br><span class="line">        <span class="keyword">if</span> <span class="variable language_">self</span>.SQL.chack_user(<span class="variable language_">self</span>.lineEdit.text(),<span class="variable language_">self</span>.lineEdit_2.text()):</span><br><span class="line">            <span class="comment"># self.Dialog = QtWidgets.QDialog()</span></span><br><span class="line">            <span class="variable language_">self</span>.ui2 = password_screen.Ui_Dialog(<span class="variable language_">self</span>.lineEdit.text())</span><br><span class="line">            <span class="variable language_">self</span>.ui2.closeWindow.connect(<span class="variable language_">self</span>.MainWindow_show)</span><br><span class="line">            <span class="comment"># self.ui2.setupUi(self.Dialog)</span></span><br><span class="line">            <span class="comment"># self.Dialog.show()</span></span><br><span class="line">            <span class="variable language_">self</span>.ui2.show()</span><br><span class="line"></span><br><span class="line">            MainWindow.hide()</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            QtWidgets.QMessageBox.about(<span class="variable language_">self</span>.MainWindow,<span class="string">&quot;提示&quot;</span>,<span class="string">&quot;用户名或密码不正确！&quot;</span>)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">MainWindow_show</span>(<span class="params">self,val</span>):</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit.setText(val)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_2.setText(<span class="string">&#x27;&#x27;</span>)</span><br><span class="line">        MainWindow.show()</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">retranslateUi</span>(<span class="params">self, MainWindow</span>):</span><br><span class="line">        _translate = QtCore.QCoreApplication.translate</span><br><span class="line">        MainWindow.setWindowTitle(_translate(<span class="string">&quot;MainWindow&quot;</span>, <span class="string">&quot;个人密码管理系统&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.label.setText(_translate(<span class="string">&quot;MainWindow&quot;</span>, <span class="string">&quot;用户名：&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.label_2.setText(_translate(<span class="string">&quot;MainWindow&quot;</span>, <span class="string">&quot;密  码：&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setText(_translate(<span class="string">&quot;MainWindow&quot;</span>, <span class="string">&quot;注册&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.setText(_translate(<span class="string">&quot;MainWindow&quot;</span>, <span class="string">&quot;登录&quot;</span>))</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ ==<span class="string">&#x27;__main__&#x27;</span>:</span><br><span class="line"></span><br><span class="line">    app = QtWidgets.QApplication(sys.argv)</span><br><span class="line">    MainWindow = QtWidgets.QMainWindow()</span><br><span class="line">    ui = Ui_MainWindow()</span><br><span class="line">    ui.setupUi(MainWindow)</span><br><span class="line">    MainWindow.show()</span><br><span class="line">    sys.exit(app.exec_())</span><br></pre></td></tr></table></figure>

<p>操作数据</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> sqlite3</span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">sql</span>():</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">__init__</span>(<span class="params">self</span>):</span><br><span class="line">        <span class="variable language_">self</span>.conn = sqlite3.connect(<span class="string">&#x27;data.db&#x27;</span>)</span><br><span class="line">        c = <span class="variable language_">self</span>.conn.cursor()</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            create_tb_cmd=<span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">            CREATE TABLE IF NOT EXISTS USER</span></span><br><span class="line"><span class="string">            (      NAME           char(50)    NOT NULL,\</span></span><br><span class="line"><span class="string">                   PASSWORD       char(50)     NOT NULL,\</span></span><br><span class="line"><span class="string">                   LEVEL    integer DEFAULT 1,\</span></span><br><span class="line"><span class="string">                   primary key (NAME));</span></span><br><span class="line"><span class="string">            &#x27;&#x27;&#x27;</span></span><br><span class="line">            c.execute(create_tb_cmd)</span><br><span class="line"></span><br><span class="line">            create_password_cmd = <span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">                    CREATE TABLE IF NOT EXISTS PASSWORD</span></span><br><span class="line"><span class="string">                    (ID INTEGER PRIMARY KEY    autoincrement,\</span></span><br><span class="line"><span class="string">                           application           char(50)    NOT NULL,\</span></span><br><span class="line"><span class="string">                           NAME           char(50)    NOT NULL,\</span></span><br><span class="line"><span class="string">                           PASSWORD       char(50)     NOT NULL,\</span></span><br><span class="line"><span class="string">                           user       char(50)     NOT NULL,\</span></span><br><span class="line"><span class="string">                           CreatedTime TimeStamp NOT NULL DEFAULT (datetime(&#x27;now&#x27;,&#x27;localtime&#x27;))</span></span><br><span class="line"><span class="string">                           );</span></span><br><span class="line"><span class="string">                    &#x27;&#x27;&#x27;</span></span><br><span class="line">            c.execute(create_password_cmd)</span><br><span class="line">            <span class="variable language_">self</span>.conn.commit()</span><br><span class="line">            <span class="comment"># self.conn.close()</span></span><br><span class="line">        <span class="keyword">except</span> Exception <span class="keyword">as</span> e:</span><br><span class="line">            <span class="built_in">print</span>(e)</span><br><span class="line">            <span class="built_in">print</span> (<span class="string">&quot;Create table failed&quot;</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">chack_user</span>(<span class="params">self,user,password</span>):</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            c = <span class="variable language_">self</span>.conn.cursor()</span><br><span class="line">            chack_pass_cmd = <span class="string">&#x27;select PASSWORD from user where NAME == &quot;&#123;&#125;&quot;&#x27;</span>.<span class="built_in">format</span>(user)</span><br><span class="line">            c.execute(chack_pass_cmd)</span><br><span class="line">            <span class="variable language_">self</span>.conn.commit()</span><br><span class="line">            passwd_list = c.fetchall()</span><br><span class="line">            <span class="built_in">print</span>(passwd_list)</span><br><span class="line">            <span class="keyword">if</span> passwd_list != []:</span><br><span class="line">                <span class="keyword">if</span> passwd_list[<span class="number">0</span>][<span class="number">0</span>] == password:</span><br><span class="line">                    <span class="keyword">return</span> <span class="literal">True</span></span><br><span class="line">                <span class="keyword">else</span>:</span><br><span class="line">                    <span class="keyword">return</span> <span class="literal">False</span></span><br><span class="line">            <span class="keyword">return</span> <span class="literal">False</span></span><br><span class="line">        <span class="keyword">except</span> Exception <span class="keyword">as</span> e:</span><br><span class="line">            <span class="built_in">print</span>(e)</span><br><span class="line">            <span class="keyword">return</span> <span class="literal">False</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">insert_user</span>(<span class="params">self,name,password</span>):</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            c = <span class="variable language_">self</span>.conn.cursor()</span><br><span class="line">            insert_user_cmd = <span class="string">&#x27;insert into user (NAME,PASSWORD) values (&quot;&#123;&#125;&quot;,&quot;&#123;&#125;&quot;)&#x27;</span>.<span class="built_in">format</span>(name,password)</span><br><span class="line">            c.execute(insert_user_cmd)</span><br><span class="line">            <span class="variable language_">self</span>.conn.commit()</span><br><span class="line">            <span class="keyword">return</span> <span class="literal">True</span></span><br><span class="line">        <span class="keyword">except</span> Exception <span class="keyword">as</span> e:</span><br><span class="line">            <span class="built_in">print</span>(e)</span><br><span class="line">            <span class="keyword">return</span> <span class="literal">False</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">insert_passwd</span>(<span class="params">self,application,name,passwd,user</span>):</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            c = <span class="variable language_">self</span>.conn.cursor()</span><br><span class="line">            insert_passwd_cmd = <span class="string">&#x27;insert into PASSWORD (application,NAME,PASSWORD,user) values (&quot;&#123;&#125;&quot;,&quot;&#123;&#125;&quot;,&quot;&#123;&#125;&quot;,&quot;&#123;&#125;&quot;)&#x27;</span>.<span class="built_in">format</span>(application,name,passwd,user)</span><br><span class="line">            c.execute(insert_passwd_cmd)</span><br><span class="line">            <span class="variable language_">self</span>.conn.commit()</span><br><span class="line">            <span class="keyword">return</span> <span class="literal">True</span></span><br><span class="line">        <span class="keyword">except</span> Exception <span class="keyword">as</span> e:</span><br><span class="line">            <span class="built_in">print</span>(e)</span><br><span class="line">            <span class="keyword">return</span> <span class="literal">False</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">select_passwdByName</span>(<span class="params">self,application</span>):</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            c = <span class="variable language_">self</span>.conn.cursor()</span><br><span class="line">            insert_passwd_cmd = <span class="string">&#x27;select * from PASSWORD where application = &quot;&#123;&#125;&quot; order by CreatedTime desc&#x27;</span>.<span class="built_in">format</span>(application)</span><br><span class="line">            c.execute(insert_passwd_cmd)</span><br><span class="line">            <span class="variable language_">self</span>.conn.commit()</span><br><span class="line">            passwd_list = c.fetchall()</span><br><span class="line">            <span class="built_in">print</span>(passwd_list)</span><br><span class="line">            <span class="keyword">return</span> passwd_list</span><br><span class="line">        <span class="keyword">except</span> Exception <span class="keyword">as</span> e:</span><br><span class="line">            <span class="built_in">print</span>(e)</span><br><span class="line">            <span class="keyword">return</span> <span class="literal">False</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">delete_passwd</span>(<span class="params">self,application,time,user</span>):</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            c = <span class="variable language_">self</span>.conn.cursor()</span><br><span class="line">            delete_passwd_cmd = <span class="string">&#x27;delete from PASSWORD where application=&quot;&#123;&#125;&quot; and CreatedTime= &quot;&#123;&#125;&quot; and user = &quot;&#123;&#125;&quot;&#x27;</span>.<span class="built_in">format</span>(application,time,user)</span><br><span class="line">            c.execute(delete_passwd_cmd)</span><br><span class="line">            <span class="variable language_">self</span>.conn.commit()</span><br><span class="line">            <span class="keyword">return</span> <span class="literal">True</span></span><br><span class="line">        <span class="keyword">except</span> Exception <span class="keyword">as</span> e:</span><br><span class="line">            <span class="built_in">print</span>(e)</span><br><span class="line">            <span class="keyword">return</span> <span class="literal">False</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">update_passwd</span>(<span class="params">self,password,application,time,user</span>):</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            c = <span class="variable language_">self</span>.conn.cursor()</span><br><span class="line">            update_passwd_cmd = <span class="string">&#x27;update PASSWORD set PASSWORD = &quot;&#123;&#125;&quot; where application=&quot;&#123;&#125;&quot; and CreatedTime= &quot;&#123;&#125;&quot; and user = &quot;&#123;&#125;&quot;&#x27;</span>.<span class="built_in">format</span>(password,application,time,user)</span><br><span class="line">            c.execute(update_passwd_cmd)</span><br><span class="line">            <span class="variable language_">self</span>.conn.commit()</span><br><span class="line">            <span class="keyword">return</span> <span class="literal">True</span></span><br><span class="line">        <span class="keyword">except</span> Exception <span class="keyword">as</span> e:</span><br><span class="line">            <span class="built_in">print</span>(e)</span><br><span class="line">            <span class="keyword">return</span> <span class="literal">False</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">select_passwd_all</span>(<span class="params">self,user</span>):</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            c = <span class="variable language_">self</span>.conn.cursor()</span><br><span class="line">            insert_passwd_cmd = <span class="string">&#x27;select * from PASSWORD where  user = &quot;&#123;&#125;&quot;  order by application asc,CreatedTime DESC&#x27;</span>.<span class="built_in">format</span>(user)</span><br><span class="line">            c.execute(insert_passwd_cmd)</span><br><span class="line">            <span class="variable language_">self</span>.conn.commit()</span><br><span class="line">            passwd_list = c.fetchall()</span><br><span class="line">            <span class="comment"># print(passwd_list)</span></span><br><span class="line">            <span class="keyword">return</span> passwd_list</span><br><span class="line">        <span class="keyword">except</span> Exception <span class="keyword">as</span> e:</span><br><span class="line">            <span class="built_in">print</span>(e)</span><br><span class="line">            <span class="keyword">return</span> []</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">select_passwd_by_like</span>(<span class="params">self,<span class="built_in">str</span>,user</span>):</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            c = <span class="variable language_">self</span>.conn.cursor()</span><br><span class="line">            insert_passwd_cmd = <span class="string">&#x27;select * from PASSWORD where user = &quot;&#123;&#125;&quot; and application like &quot;%&#123;&#125;%&quot;  order by application asc,CreatedTime DESC&#x27;</span>.<span class="built_in">format</span>(user,<span class="built_in">str</span>)</span><br><span class="line">            c.execute(insert_passwd_cmd)</span><br><span class="line">            <span class="variable language_">self</span>.conn.commit()</span><br><span class="line">            passwd_list = c.fetchall()</span><br><span class="line">            <span class="comment"># print(passwd_list)</span></span><br><span class="line">            <span class="keyword">return</span> passwd_list</span><br><span class="line">        <span class="keyword">except</span> Exception <span class="keyword">as</span> e:</span><br><span class="line">            <span class="built_in">print</span>(e)</span><br><span class="line">            <span class="keyword">return</span> []</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">close</span>(<span class="params">self</span>):</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            <span class="variable language_">self</span>.conn.close()</span><br><span class="line">        <span class="keyword">except</span>:</span><br><span class="line">            <span class="keyword">pass</span></span><br></pre></td></tr></table></figure>

<p>显示密码界面</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Form implementation generated from reading ui file &#x27;password_screen.ui&#x27;</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Created by: PyQt5 UI code generator 5.10.1</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># WARNING! All changes made in this file will be lost!</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> PyQt5 <span class="keyword">import</span> QtCore, QtGui, QtWidgets</span><br><span class="line"><span class="keyword">from</span> PyQt5.QtCore <span class="keyword">import</span> pyqtSignal</span><br><span class="line"><span class="keyword">from</span> PyQt5.QtWidgets <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">import</span> connectData</span><br><span class="line"><span class="keyword">import</span> password</span><br><span class="line"><span class="keyword">import</span> search</span><br><span class="line"></span><br><span class="line"><span class="keyword">import</span> background_rc</span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Ui_Dialog</span>(<span class="title class_ inherited__">QDialog</span>):</span><br><span class="line">    closeWindow = pyqtSignal(<span class="built_in">str</span>)</span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">__init__</span>(<span class="params">self,user</span>):</span><br><span class="line">        <span class="built_in">super</span>(QDialog, <span class="variable language_">self</span>).__init__()</span><br><span class="line">        <span class="variable language_">self</span>.user = user</span><br><span class="line">        <span class="variable language_">self</span>.search_str = <span class="string">&#x27;&#x27;</span></span><br><span class="line">        <span class="variable language_">self</span>.setupUi(<span class="variable language_">self</span>)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">setupUi</span>(<span class="params">self, Dialog</span>):</span><br><span class="line">        Dialog.setObjectName(<span class="string">&quot;Dialog&quot;</span>)</span><br><span class="line">        Dialog.resize(<span class="number">750</span>, <span class="number">600</span>)</span><br><span class="line"></span><br><span class="line">        icon = QtGui.QIcon()</span><br><span class="line">        icon.addPixmap(QtGui.QPixmap(<span class="string">&quot;:/icon/wb.ico&quot;</span>), QtGui.QIcon.Normal, QtGui.QIcon.Off)</span><br><span class="line">        Dialog.setWindowIcon(icon)</span><br><span class="line">        <span class="variable language_">self</span>.setWindowFlags(QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowCloseButtonHint)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout_2 = QtWidgets.QVBoxLayout(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout_2.setObjectName(<span class="string">&quot;verticalLayout_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.groupBox = QtWidgets.QGroupBox(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.groupBox.setTitle(<span class="string">&quot;&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.groupBox.setObjectName(<span class="string">&quot;groupBox&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3 = QtWidgets.QHBoxLayout(<span class="variable language_">self</span>.groupBox)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.setObjectName(<span class="string">&quot;horizontalLayout_3&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout = QtWidgets.QVBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.setObjectName(<span class="string">&quot;verticalLayout&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.setObjectName(<span class="string">&quot;horizontalLayout&quot;</span>)</span><br><span class="line">        spacerItem = QtWidgets.QSpacerItem(<span class="number">40</span>, <span class="number">20</span>, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addItem(spacerItem)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_5 = QtWidgets.QPushButton(<span class="variable language_">self</span>.groupBox)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_5.setMinimumSize(QtCore.QSize(<span class="number">20</span>, <span class="number">20</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_5.setMaximumSize(QtCore.QSize(<span class="number">20</span>, <span class="number">20</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_5.setStyleSheet(<span class="string">&quot;\n&quot;</span></span><br><span class="line"><span class="string">&quot;QPushButton&#123;background-color:rgb(104, 104, 104);color: white;     border: 2px groove gray;border-style: outset;\n&quot;</span></span><br><span class="line"><span class="string">&quot;image: url(:/image/select.ico);&#125;\n&quot;</span></span><br><span class="line"><span class="string">&quot;\n&quot;</span></span><br><span class="line"><span class="string">&quot;QPushButton:pressed&#123;background-color:rgb(85, 170, 255); border-style: inset;border-image: url(:/image/select.ico); &#125;&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_5.setText(<span class="string">&quot;&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_5.setObjectName(<span class="string">&quot;pushButton_5&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addWidget(<span class="variable language_">self</span>.pushButton_5)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton = QtWidgets.QPushButton(<span class="variable language_">self</span>.groupBox)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setMinimumSize(QtCore.QSize(<span class="number">20</span>, <span class="number">20</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setMaximumSize(QtCore.QSize(<span class="number">20</span>, <span class="number">20</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setStyleSheet(<span class="string">&quot;\n&quot;</span></span><br><span class="line"><span class="string">&quot;QPushButton&#123;background-color:rgb(104, 104, 104);color: white;     border: 2px groove gray;border-style: outset;\n&quot;</span></span><br><span class="line"><span class="string">&quot;image: url(:/image/add.ico);&#125;\n&quot;</span></span><br><span class="line"><span class="string">&quot;\n&quot;</span></span><br><span class="line"><span class="string">&quot;QPushButton:pressed&#123;background-color:rgb(85, 170, 255); border-style: inset;border-image: url(:/image/add.ico); &#125;&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setText(<span class="string">&quot;&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setObjectName(<span class="string">&quot;pushButton&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addWidget(<span class="variable language_">self</span>.pushButton)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2 = QtWidgets.QPushButton(<span class="variable language_">self</span>.groupBox)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.setMinimumSize(QtCore.QSize(<span class="number">20</span>, <span class="number">20</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.setMaximumSize(QtCore.QSize(<span class="number">20</span>, <span class="number">20</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.setStyleSheet(<span class="string">&quot;\n&quot;</span></span><br><span class="line"><span class="string">&quot;QPushButton&#123;background-color:rgb(104, 104, 104);color: white;     border: 2px groove gray;border-style: outset;\n&quot;</span></span><br><span class="line"><span class="string">&quot;image: url(:/image/delete.ico);&#125;\n&quot;</span></span><br><span class="line"><span class="string">&quot;\n&quot;</span></span><br><span class="line"><span class="string">&quot;QPushButton:pressed&#123;background-color:rgb(85, 170, 255); border-style: inset;border-image: url(:/image/delete.ico); &#125;&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.setText(<span class="string">&quot;&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.setObjectName(<span class="string">&quot;pushButton_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addWidget(<span class="variable language_">self</span>.pushButton_2)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout)</span><br><span class="line">        <span class="variable language_">self</span>.tableWidget = QtWidgets.QTableWidget(<span class="variable language_">self</span>.groupBox)</span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setEnabled(<span class="literal">True</span>)</span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setToolTip(<span class="string">&quot;&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setObjectName(<span class="string">&quot;tableWidget&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setColumnCount(<span class="number">4</span>)</span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setRowCount(<span class="number">0</span>)</span><br><span class="line">        item = QtWidgets.QTableWidgetItem()</span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setHorizontalHeaderItem(<span class="number">0</span>, item)</span><br><span class="line">        item = QtWidgets.QTableWidgetItem()</span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setHorizontalHeaderItem(<span class="number">1</span>, item)</span><br><span class="line">        item = QtWidgets.QTableWidgetItem()</span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setHorizontalHeaderItem(<span class="number">2</span>, item)</span><br><span class="line">        item = QtWidgets.QTableWidgetItem()</span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setHorizontalHeaderItem(<span class="number">3</span>, item)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addWidget(<span class="variable language_">self</span>.tableWidget)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2 = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.setObjectName(<span class="string">&quot;horizontalLayout_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout_2)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.addLayout(<span class="variable language_">self</span>.verticalLayout)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout_2.addWidget(<span class="variable language_">self</span>.groupBox)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.retranslateUi(Dialog)</span><br><span class="line">        QtCore.QMetaObject.connectSlotsByName(Dialog)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">retranslateUi</span>(<span class="params">self, Dialog</span>):</span><br><span class="line">        _translate = QtCore.QCoreApplication.translate</span><br><span class="line">        Dialog.setWindowTitle(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;Dialog&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_5.setToolTip(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;查找&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setToolTip(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;添加&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.setToolTip(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;删除&quot;</span>))</span><br><span class="line">        item = <span class="variable language_">self</span>.tableWidget.horizontalHeaderItem(<span class="number">0</span>)</span><br><span class="line">        item.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;应用&quot;</span>))</span><br><span class="line">        item = <span class="variable language_">self</span>.tableWidget.horizontalHeaderItem(<span class="number">1</span>)</span><br><span class="line">        item.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;用户名&quot;</span>))</span><br><span class="line">        item = <span class="variable language_">self</span>.tableWidget.horizontalHeaderItem(<span class="number">2</span>)</span><br><span class="line">        item.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;密码&quot;</span>))</span><br><span class="line">        item = <span class="variable language_">self</span>.tableWidget.horizontalHeaderItem(<span class="number">3</span>)</span><br><span class="line">        item.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;时间&quot;</span>))</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.pushButton.clicked.connect(<span class="variable language_">self</span>.addclick)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.clicked.connect(<span class="variable language_">self</span>.deleteclick)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_5.clicked.connect(<span class="variable language_">self</span>.search_app)</span><br><span class="line">        Dialog.setWindowTitle(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;&#123;&#125;&quot;</span>.<span class="built_in">format</span>(<span class="variable language_">self</span>.user)))</span><br><span class="line">        <span class="variable language_">self</span>.SQL = connectData.sql()</span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setColumnWidth(<span class="number">3</span>, <span class="number">200</span>)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.update_UI()</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.doubleClicked.connect(<span class="variable language_">self</span>.table_change)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)  <span class="comment">######允许右键产生子菜单</span></span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.customContextMenuRequested.connect(<span class="variable language_">self</span>.custom_right_menu)  <span class="comment">####右键菜单</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">custom_right_menu</span>(<span class="params">self, pos</span>):</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            menu = QMenu()</span><br><span class="line">            opt2 = menu.addAction(<span class="string">&quot;添加&quot;</span>)</span><br><span class="line">            opt1 = menu.addAction(<span class="string">&quot;删除&quot;</span>)</span><br><span class="line">            action = menu.exec_(<span class="variable language_">self</span>.tableWidget.mapToGlobal(pos))</span><br><span class="line">            <span class="keyword">if</span> action == opt1:</span><br><span class="line">                <span class="variable language_">self</span>.deleteclick()</span><br><span class="line">            <span class="keyword">elif</span> action == opt2:</span><br><span class="line"></span><br><span class="line">                application = <span class="variable language_">self</span>.tableWidget.item(<span class="variable language_">self</span>.tableWidget.currentRow(), <span class="number">0</span>).text()</span><br><span class="line">                name = <span class="variable language_">self</span>.tableWidget.item(<span class="variable language_">self</span>.tableWidget.currentRow(), <span class="number">1</span>).text()</span><br><span class="line"></span><br><span class="line">                <span class="comment"># self.Dialog = QtWidgets.QDialog()</span></span><br><span class="line">                <span class="variable language_">self</span>.ui2 = password.Ui_Dialog(<span class="variable language_">self</span>.user, application, name, <span class="string">&#x27;&#x27;</span>, <span class="string">&#x27;&#x27;</span>, <span class="literal">False</span>)</span><br><span class="line">                <span class="variable language_">self</span>.ui2.closeWindow.connect(<span class="variable language_">self</span>.update_UI)</span><br><span class="line">                <span class="comment"># self.ui2.setupUi(self.Dialog)</span></span><br><span class="line">                <span class="variable language_">self</span>.ui2.show()</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                <span class="keyword">return</span></span><br><span class="line">        <span class="keyword">except</span> Exception <span class="keyword">as</span> e:</span><br><span class="line">            <span class="built_in">print</span>(e)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">table_change</span>(<span class="params">self</span>):</span><br><span class="line"></span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            application = <span class="variable language_">self</span>.tableWidget.item(<span class="variable language_">self</span>.tableWidget.currentRow(), <span class="number">0</span>).text()</span><br><span class="line">            name = <span class="variable language_">self</span>.tableWidget.item(<span class="variable language_">self</span>.tableWidget.currentRow(), <span class="number">1</span>).text()</span><br><span class="line">            password_str = <span class="variable language_">self</span>.tableWidget.item(<span class="variable language_">self</span>.tableWidget.currentRow(), <span class="number">2</span>).text()</span><br><span class="line">            time_str = <span class="variable language_">self</span>.tableWidget.item(<span class="variable language_">self</span>.tableWidget.currentRow(), <span class="number">3</span>).text()</span><br><span class="line"></span><br><span class="line">            <span class="comment"># self.Dialog = QtWidgets.QDialog()</span></span><br><span class="line">            <span class="variable language_">self</span>.ui2 = password.Ui_Dialog(<span class="variable language_">self</span>.user, application, name, password_str, time_str, <span class="literal">True</span>)</span><br><span class="line">            <span class="variable language_">self</span>.ui2.closeWindow.connect(<span class="variable language_">self</span>.update_UI)</span><br><span class="line">            <span class="comment"># self.ui2.setupUi(self.Dialog)</span></span><br><span class="line">            <span class="variable language_">self</span>.ui2.show()</span><br><span class="line">        <span class="keyword">except</span> Exception <span class="keyword">as</span> e:</span><br><span class="line">            <span class="built_in">print</span>(e)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">update_UI</span>(<span class="params">self, app_str=<span class="string">&#x27;&#x27;</span></span>):</span><br><span class="line">        <span class="variable language_">self</span>.search_str = app_str</span><br><span class="line">        <span class="keyword">if</span> <span class="variable language_">self</span>.search_str == <span class="string">&#x27;&#x27;</span>:</span><br><span class="line">            password_list = <span class="variable language_">self</span>.SQL.select_passwd_all(<span class="variable language_">self</span>.user)</span><br><span class="line">            _translate = QtCore.QCoreApplication.translate</span><br><span class="line">            item = <span class="variable language_">self</span>.tableWidget.horizontalHeaderItem(<span class="number">0</span>)</span><br><span class="line">            item.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;应用&quot;</span>))</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            password_list = <span class="variable language_">self</span>.SQL.select_passwd_by_like(app_str, <span class="variable language_">self</span>.user)</span><br><span class="line">            _translate = QtCore.QCoreApplication.translate</span><br><span class="line">            item = <span class="variable language_">self</span>.tableWidget.horizontalHeaderItem(<span class="number">0</span>)</span><br><span class="line">            item.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;应用(&#123;&#125;)&quot;</span>.<span class="built_in">format</span>(<span class="variable language_">self</span>.search_str)))</span><br><span class="line"></span><br><span class="line">        <span class="built_in">print</span>(password_list)</span><br><span class="line">        <span class="variable language_">self</span>.tableWidget.setRowCount(<span class="built_in">len</span>(password_list))</span><br><span class="line">        <span class="keyword">for</span> index1, data <span class="keyword">in</span> <span class="built_in">enumerate</span>(password_list):</span><br><span class="line">            <span class="variable language_">self</span>.tableWidget.setItem(index1, <span class="number">0</span>, QTableWidgetItem(data[<span class="number">1</span>]))</span><br><span class="line">            <span class="variable language_">self</span>.tableWidget.setItem(index1, <span class="number">1</span>, QTableWidgetItem(data[<span class="number">2</span>]))</span><br><span class="line">            <span class="variable language_">self</span>.tableWidget.setItem(index1, <span class="number">2</span>, QTableWidgetItem(data[<span class="number">3</span>]))</span><br><span class="line">            <span class="variable language_">self</span>.tableWidget.setItem(index1, <span class="number">3</span>, QTableWidgetItem(data[<span class="number">5</span>]))</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">addclick</span>(<span class="params">self</span>):</span><br><span class="line"></span><br><span class="line">        <span class="comment"># self.Dialog = QtWidgets.QDialog()</span></span><br><span class="line">        <span class="variable language_">self</span>.ui2 = password.Ui_Dialog(<span class="variable language_">self</span>.user)</span><br><span class="line">        <span class="variable language_">self</span>.ui2.closeWindow.connect(<span class="variable language_">self</span>.update_UI)</span><br><span class="line">        <span class="comment"># self.ui2.setupUi(self.Dialog)</span></span><br><span class="line">        <span class="variable language_">self</span>.ui2.show()</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">deleteclick</span>(<span class="params">self</span>):</span><br><span class="line">        reply = QtWidgets.QMessageBox.question(<span class="variable language_">self</span>,</span><br><span class="line">                                               <span class="string">&#x27;确认&#x27;</span>,</span><br><span class="line">                                               <span class="string">&quot;是否要删除这条记录？&quot;</span>,</span><br><span class="line">                                               QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No,</span><br><span class="line">                                               QtWidgets.QMessageBox.No)</span><br><span class="line">        <span class="keyword">if</span> reply == QtWidgets.QMessageBox.Yes:</span><br><span class="line">            <span class="keyword">try</span>:</span><br><span class="line">                application = <span class="variable language_">self</span>.tableWidget.item(<span class="variable language_">self</span>.tableWidget.currentRow(), <span class="number">0</span>).text()</span><br><span class="line">                name = <span class="variable language_">self</span>.tableWidget.item(<span class="variable language_">self</span>.tableWidget.currentRow(), <span class="number">1</span>).text()</span><br><span class="line">                password = <span class="variable language_">self</span>.tableWidget.item(<span class="variable language_">self</span>.tableWidget.currentRow(), <span class="number">2</span>).text()</span><br><span class="line">                time_str = <span class="variable language_">self</span>.tableWidget.item(<span class="variable language_">self</span>.tableWidget.currentRow(), <span class="number">3</span>).text()</span><br><span class="line">                <span class="keyword">if</span> <span class="variable language_">self</span>.SQL.delete_passwd(application, time_str, <span class="variable language_">self</span>.user):</span><br><span class="line">                    <span class="variable language_">self</span>.tableWidget.removeRow(<span class="variable language_">self</span>.tableWidget.currentRow())</span><br><span class="line">                <span class="keyword">else</span>:</span><br><span class="line">                    QtWidgets.QMessageBox.about(<span class="variable language_">self</span>, <span class="string">&#x27;提示&#x27;</span>, <span class="string">&#x27;删除失败！&#x27;</span>)</span><br><span class="line">            <span class="keyword">except</span>:</span><br><span class="line">                QtWidgets.QMessageBox.about(<span class="variable language_">self</span>, <span class="string">&#x27;提示&#x27;</span>, <span class="string">&#x27;请选择删除项！&#x27;</span>)</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">             <span class="keyword">pass</span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">search_app</span>(<span class="params">self</span>):</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.ui2 = search.Ui_Dialog(<span class="variable language_">self</span>.search_str)</span><br><span class="line">        <span class="variable language_">self</span>.ui2.closeWindow.connect(<span class="variable language_">self</span>.update_UI)</span><br><span class="line">        <span class="comment"># self.ui2.setupUi(self.Dialog)</span></span><br><span class="line">        <span class="variable language_">self</span>.ui2.show()</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">closeEvent</span>(<span class="params">self, a0: QtGui.QCloseEvent</span>) -&gt; <span class="literal">None</span>:</span><br><span class="line">        <span class="variable language_">self</span>.closeWindow.emit(<span class="variable language_">self</span>.user)</span><br></pre></td></tr></table></figure>

<p>注册用户界面</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Form implementation generated from reading ui file &#x27;sign_in.ui&#x27;</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Created by: PyQt5 UI code generator 5.10.1</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># WARNING! All changes made in this file will be lost!</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> PyQt5 <span class="keyword">import</span> QtCore, QtGui, QtWidgets</span><br><span class="line"><span class="keyword">from</span> PyQt5.QtCore <span class="keyword">import</span> pyqtSignal</span><br><span class="line"><span class="keyword">from</span> PyQt5.QtWidgets <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">import</span> connectData</span><br><span class="line"><span class="keyword">import</span> background_rc</span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Ui_Dialog</span>(<span class="title class_ inherited__">QDialog</span>):</span><br><span class="line"></span><br><span class="line">    closeWindow = pyqtSignal(<span class="built_in">str</span>)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">setupUi</span>(<span class="params">self, Dialog</span>):</span><br><span class="line">        Dialog.setObjectName(<span class="string">&quot;Dialog&quot;</span>)</span><br><span class="line">        Dialog.resize(<span class="number">400</span>, <span class="number">300</span>)</span><br><span class="line">        icon = QtGui.QIcon()</span><br><span class="line">        icon.addPixmap(QtGui.QPixmap(<span class="string">&quot;:/icon/wb.ico&quot;</span>), QtGui.QIcon.Normal, QtGui.QIcon.Off)</span><br><span class="line">        Dialog.setWindowIcon(icon)</span><br><span class="line">        Dialog.setWindowFlags(</span><br><span class="line">            QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowCloseButtonHint)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.Dialog = Dialog</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout = QtWidgets.QHBoxLayout(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.setObjectName(<span class="string">&quot;horizontalLayout&quot;</span>)</span><br><span class="line">        spacerItem = QtWidgets.QSpacerItem(<span class="number">40</span>, <span class="number">20</span>, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addItem(spacerItem)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout = QtWidgets.QVBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.setObjectName(<span class="string">&quot;verticalLayout&quot;</span>)</span><br><span class="line">        spacerItem1 = QtWidgets.QSpacerItem(<span class="number">20</span>, <span class="number">40</span>, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addItem(spacerItem1)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2 = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.setObjectName(<span class="string">&quot;horizontalLayout_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.label = QtWidgets.QLabel(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.label.setObjectName(<span class="string">&quot;label&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.addWidget(<span class="variable language_">self</span>.label)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit = QtWidgets.QLineEdit(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit.setObjectName(<span class="string">&quot;lineEdit&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.addWidget(<span class="variable language_">self</span>.lineEdit)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout_2)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3 = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.setObjectName(<span class="string">&quot;horizontalLayout_3&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.label_2 = QtWidgets.QLabel(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.label_2.setObjectName(<span class="string">&quot;label_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.addWidget(<span class="variable language_">self</span>.label_2)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_2 = QtWidgets.QLineEdit(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_2.setObjectName(<span class="string">&quot;lineEdit_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.addWidget(<span class="variable language_">self</span>.lineEdit_2)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout_3)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_5 = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_5.setObjectName(<span class="string">&quot;horizontalLayout_5&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.label_3 = QtWidgets.QLabel(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.label_3.setObjectName(<span class="string">&quot;label_3&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_5.addWidget(<span class="variable language_">self</span>.label_3)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_3 = QtWidgets.QLineEdit(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_3.setObjectName(<span class="string">&quot;lineEdit_3&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_5.addWidget(<span class="variable language_">self</span>.lineEdit_3)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout_5)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4 = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4.setObjectName(<span class="string">&quot;horizontalLayout_4&quot;</span>)</span><br><span class="line">        spacerItem2 = QtWidgets.QSpacerItem(<span class="number">40</span>, <span class="number">20</span>, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4.addItem(spacerItem2)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton = QtWidgets.QPushButton(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setObjectName(<span class="string">&quot;pushButton&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4.addWidget(<span class="variable language_">self</span>.pushButton, <span class="number">0</span>, QtCore.Qt.AlignHCenter)</span><br><span class="line">        spacerItem3 = QtWidgets.QSpacerItem(<span class="number">40</span>, <span class="number">20</span>, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4.addItem(spacerItem3)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout_4)</span><br><span class="line">        spacerItem4 = QtWidgets.QSpacerItem(<span class="number">20</span>, <span class="number">40</span>, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addItem(spacerItem4)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addLayout(<span class="variable language_">self</span>.verticalLayout)</span><br><span class="line">        spacerItem5 = QtWidgets.QSpacerItem(<span class="number">40</span>, <span class="number">20</span>, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addItem(spacerItem5)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.retranslateUi(Dialog)</span><br><span class="line">        QtCore.QMetaObject.connectSlotsByName(Dialog)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">retranslateUi</span>(<span class="params">self, Dialog</span>):</span><br><span class="line">        _translate = QtCore.QCoreApplication.translate</span><br><span class="line">        Dialog.setWindowTitle(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;注册&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.label.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;用户名：&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.label_2.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;密  码：&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.label_3.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;确  认：&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;注册&quot;</span>))</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.pushButton.clicked.connect(<span class="variable language_">self</span>.sign_in)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">sign_in</span>(<span class="params">self</span>):</span><br><span class="line">        <span class="variable language_">self</span>.SQL = connectData.sql()</span><br><span class="line">        <span class="keyword">if</span> <span class="variable language_">self</span>.lineEdit_2.text() == <span class="variable language_">self</span>.lineEdit_3.text():</span><br><span class="line">            <span class="keyword">if</span> <span class="variable language_">self</span>.SQL.insert_user(<span class="variable language_">self</span>.lineEdit.text(),<span class="variable language_">self</span>.lineEdit_2.text()):</span><br><span class="line">                <span class="variable language_">self</span>.closeWindow.emit(<span class="built_in">str</span>(<span class="variable language_">self</span>.lineEdit.text()))</span><br><span class="line">                <span class="variable language_">self</span>.SQL.close()</span><br><span class="line">                <span class="variable language_">self</span>.Dialog.close()</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                QtWidgets.QMessageBox.about(<span class="variable language_">self</span>.Dialog,<span class="string">&#x27;提示&#x27;</span>,<span class="string">&#x27;用户已存在！&#x27;</span>)</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            QtWidgets.QMessageBox.about(<span class="variable language_">self</span>.Dialog,<span class="string">&#x27;提示&#x27;</span>,<span class="string">&#x27;请确认密码！&#x27;</span>)</span><br></pre></td></tr></table></figure>

<p>添加修改密码界面</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Form implementation generated from reading ui file &#x27;password.ui&#x27;</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Created by: PyQt5 UI code generator 5.10.1</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># WARNING! All changes made in this file will be lost!</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> PyQt5 <span class="keyword">import</span> QtCore, QtGui, QtWidgets</span><br><span class="line"><span class="keyword">from</span> PyQt5.QtCore <span class="keyword">import</span> pyqtSignal</span><br><span class="line"><span class="keyword">from</span> PyQt5.QtWidgets <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">import</span> connectData</span><br><span class="line"><span class="keyword">import</span> background_rc</span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Ui_Dialog</span>(<span class="title class_ inherited__">QDialog</span>):</span><br><span class="line">    closeWindow = pyqtSignal()</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">__init__</span>(<span class="params">self, user,application = <span class="string">&#x27;&#x27;</span>,name = <span class="string">&#x27;&#x27;</span>,password = <span class="string">&#x27;&#x27;</span>,time_str = <span class="string">&#x27;&#x27;</span>,update = <span class="literal">False</span></span>):</span><br><span class="line">        <span class="built_in">super</span>(QDialog, <span class="variable language_">self</span>).__init__()</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.user = user</span><br><span class="line">        <span class="variable language_">self</span>.application = application</span><br><span class="line">        <span class="variable language_">self</span>.name = name</span><br><span class="line">        <span class="variable language_">self</span>.password = password</span><br><span class="line">        <span class="variable language_">self</span>.update_tag = update</span><br><span class="line">        <span class="variable language_">self</span>.time_str = time_str</span><br><span class="line">        <span class="variable language_">self</span>.setupUi(<span class="variable language_">self</span>)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">setupUi</span>(<span class="params">self, Dialog</span>):</span><br><span class="line">        Dialog.setObjectName(<span class="string">&quot;Dialog&quot;</span>)</span><br><span class="line">        Dialog.resize(<span class="number">320</span>, <span class="number">220</span>)</span><br><span class="line">        icon = QtGui.QIcon()</span><br><span class="line">        icon.addPixmap(QtGui.QPixmap(<span class="string">&quot;:/icon/wb.ico&quot;</span>), QtGui.QIcon.Normal, QtGui.QIcon.Off)</span><br><span class="line">        Dialog.setWindowIcon(icon)</span><br><span class="line">        <span class="variable language_">self</span>.setWindowFlags(</span><br><span class="line">            QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowCloseButtonHint)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.Dialog = Dialog</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4 = QtWidgets.QHBoxLayout(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4.setObjectName(<span class="string">&quot;horizontalLayout_4&quot;</span>)</span><br><span class="line">        spacerItem = QtWidgets.QSpacerItem(<span class="number">40</span>, <span class="number">20</span>, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4.addItem(spacerItem)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout = QtWidgets.QVBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.setObjectName(<span class="string">&quot;verticalLayout&quot;</span>)</span><br><span class="line">        spacerItem1 = QtWidgets.QSpacerItem(<span class="number">20</span>, <span class="number">40</span>, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addItem(spacerItem1)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.setObjectName(<span class="string">&quot;horizontalLayout&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.label = QtWidgets.QLabel(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.label.setObjectName(<span class="string">&quot;label&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addWidget(<span class="variable language_">self</span>.label)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit = QtWidgets.QLineEdit(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit.setObjectName(<span class="string">&quot;lineEdit&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addWidget(<span class="variable language_">self</span>.lineEdit)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2 = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.setObjectName(<span class="string">&quot;horizontalLayout_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.label_2 = QtWidgets.QLabel(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.label_2.setObjectName(<span class="string">&quot;label_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.addWidget(<span class="variable language_">self</span>.label_2)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_2 = QtWidgets.QLineEdit(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_2.setObjectName(<span class="string">&quot;lineEdit_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.addWidget(<span class="variable language_">self</span>.lineEdit_2)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout_2)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3 = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.setObjectName(<span class="string">&quot;horizontalLayout_3&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.label_3 = QtWidgets.QLabel(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.label_3.setObjectName(<span class="string">&quot;label_3&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.addWidget(<span class="variable language_">self</span>.label_3)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_3 = QtWidgets.QLineEdit(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_3.setObjectName(<span class="string">&quot;lineEdit_3&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.addWidget(<span class="variable language_">self</span>.lineEdit_3)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout_3)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_5 = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_5.setObjectName(<span class="string">&quot;horizontalLayout_5&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout_5)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton = QtWidgets.QPushButton(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setObjectName(<span class="string">&quot;pushButton&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addWidget(<span class="variable language_">self</span>.pushButton, <span class="number">0</span>, QtCore.Qt.AlignHCenter)</span><br><span class="line">        spacerItem2 = QtWidgets.QSpacerItem(<span class="number">20</span>, <span class="number">40</span>, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addItem(spacerItem2)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4.addLayout(<span class="variable language_">self</span>.verticalLayout)</span><br><span class="line">        spacerItem3 = QtWidgets.QSpacerItem(<span class="number">40</span>, <span class="number">20</span>, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_4.addItem(spacerItem3)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.retranslateUi(Dialog)</span><br><span class="line">        QtCore.QMetaObject.connectSlotsByName(Dialog)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">retranslateUi</span>(<span class="params">self, Dialog</span>):</span><br><span class="line">        _translate = QtCore.QCoreApplication.translate</span><br><span class="line">        Dialog.setWindowTitle(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;密码&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.label.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;应用名称：&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.label_2.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;用 户 名：&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.label_3.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;密    码：&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;确定&quot;</span>))</span><br><span class="line">        <span class="keyword">if</span> <span class="variable language_">self</span>.update_tag:</span><br><span class="line">            <span class="variable language_">self</span>.lineEdit.setDisabled(<span class="literal">True</span>)</span><br><span class="line">            <span class="variable language_">self</span>.lineEdit_2.setDisabled(<span class="literal">True</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.lineEdit.setText(<span class="variable language_">self</span>.application)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_2.setText(<span class="variable language_">self</span>.name)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit_3.setText(<span class="variable language_">self</span>.password)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.pushButton.clicked.connect(<span class="variable language_">self</span>.add_password)</span><br><span class="line">        <span class="variable language_">self</span>.SQL = connectData.sql()</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">add_password</span>(<span class="params">self</span>):</span><br><span class="line">        <span class="keyword">if</span> <span class="variable language_">self</span>.update_tag:</span><br><span class="line"></span><br><span class="line">            <span class="keyword">if</span> <span class="variable language_">self</span>.SQL.update_passwd(<span class="variable language_">self</span>.lineEdit_3.text(),<span class="variable language_">self</span>.lineEdit.text(),<span class="variable language_">self</span>.time_str,<span class="variable language_">self</span>.user):</span><br><span class="line">                <span class="variable language_">self</span>.SQL.close()</span><br><span class="line">                <span class="variable language_">self</span>.closeWindow.emit()</span><br><span class="line">                <span class="variable language_">self</span>.Dialog.close()</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                QtWidgets.QMessageBox.about(<span class="variable language_">self</span>, <span class="string">&#x27;提示&#x27;</span>, <span class="string">&#x27;错误！&#x27;</span>)</span><br><span class="line">                <span class="comment"># self.Dialog.close()</span></span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line"></span><br><span class="line">            <span class="keyword">if</span> <span class="variable language_">self</span>.SQL.insert_passwd(<span class="variable language_">self</span>.lineEdit.text(),<span class="variable language_">self</span>.lineEdit_2.text(),<span class="variable language_">self</span>.lineEdit_3.text(),<span class="variable language_">self</span>.user):</span><br><span class="line">                <span class="variable language_">self</span>.SQL.close()</span><br><span class="line">                <span class="variable language_">self</span>.closeWindow.emit()</span><br><span class="line">                <span class="variable language_">self</span>.Dialog.close()</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                QtWidgets.QMessageBox.about(<span class="variable language_">self</span>, <span class="string">&#x27;提示&#x27;</span>, <span class="string">&#x27;错误！&#x27;</span>)</span><br></pre></td></tr></table></figure>

<p>查询界面</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Form implementation generated from reading ui file &#x27;search.ui&#x27;</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># Created by: PyQt5 UI code generator 5.10.1</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># WARNING! All changes made in this file will be lost!</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">from</span> PyQt5 <span class="keyword">import</span> QtCore, QtGui, QtWidgets</span><br><span class="line"><span class="keyword">from</span> PyQt5.QtCore <span class="keyword">import</span> pyqtSignal</span><br><span class="line"><span class="keyword">from</span> PyQt5.QtWidgets <span class="keyword">import</span> *</span><br><span class="line"><span class="keyword">import</span> background_rc</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">Ui_Dialog</span>(<span class="title class_ inherited__">QDialog</span>):</span><br><span class="line">    closeWindow = pyqtSignal(<span class="built_in">str</span>)</span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">__init__</span>(<span class="params">self,search_str</span>):</span><br><span class="line">        <span class="built_in">super</span>(QDialog, <span class="variable language_">self</span>).__init__()</span><br><span class="line">        <span class="variable language_">self</span>.search_str = search_str</span><br><span class="line">        <span class="variable language_">self</span>.setupUi(<span class="variable language_">self</span>)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">setupUi</span>(<span class="params">self, Dialog</span>):</span><br><span class="line">        Dialog.setObjectName(<span class="string">&quot;Dialog&quot;</span>)</span><br><span class="line">        Dialog.resize(<span class="number">300</span>, <span class="number">150</span>)</span><br><span class="line">        icon = QtGui.QIcon()</span><br><span class="line">        icon.addPixmap(QtGui.QPixmap(<span class="string">&quot;:/icon/wb.ico&quot;</span>), QtGui.QIcon.Normal, QtGui.QIcon.Off)</span><br><span class="line">        Dialog.setWindowIcon(icon)</span><br><span class="line">        <span class="variable language_">self</span>.setWindowFlags(</span><br><span class="line">            QtCore.Qt.WindowMaximizeButtonHint | QtCore.Qt.WindowMinimizeButtonHint | QtCore.Qt.WindowCloseButtonHint)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3 = QtWidgets.QHBoxLayout(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.setObjectName(<span class="string">&quot;horizontalLayout_3&quot;</span>)</span><br><span class="line">        spacerItem = QtWidgets.QSpacerItem(<span class="number">40</span>, <span class="number">20</span>, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.addItem(spacerItem)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout = QtWidgets.QVBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.setObjectName(<span class="string">&quot;verticalLayout&quot;</span>)</span><br><span class="line">        spacerItem1 = QtWidgets.QSpacerItem(<span class="number">20</span>, <span class="number">40</span>, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addItem(spacerItem1)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.setObjectName(<span class="string">&quot;horizontalLayout&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.label = QtWidgets.QLabel(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.label.setObjectName(<span class="string">&quot;label&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addWidget(<span class="variable language_">self</span>.label)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit = QtWidgets.QLineEdit(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.lineEdit.setObjectName(<span class="string">&quot;lineEdit&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout.addWidget(<span class="variable language_">self</span>.lineEdit)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout)</span><br><span class="line">        spacerItem2 = QtWidgets.QSpacerItem(<span class="number">20</span>, <span class="number">40</span>, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addItem(spacerItem2)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2 = QtWidgets.QHBoxLayout()</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.setObjectName(<span class="string">&quot;horizontalLayout_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton = QtWidgets.QPushButton(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setObjectName(<span class="string">&quot;pushButton&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.addWidget(<span class="variable language_">self</span>.pushButton)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2 = QtWidgets.QPushButton(Dialog)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.setObjectName(<span class="string">&quot;pushButton_2&quot;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_2.addWidget(<span class="variable language_">self</span>.pushButton_2)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addLayout(<span class="variable language_">self</span>.horizontalLayout_2)</span><br><span class="line">        spacerItem3 = QtWidgets.QSpacerItem(<span class="number">20</span>, <span class="number">40</span>, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)</span><br><span class="line">        <span class="variable language_">self</span>.verticalLayout.addItem(spacerItem3)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.addLayout(<span class="variable language_">self</span>.verticalLayout)</span><br><span class="line">        spacerItem4 = QtWidgets.QSpacerItem(<span class="number">40</span>, <span class="number">20</span>, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)</span><br><span class="line">        <span class="variable language_">self</span>.horizontalLayout_3.addItem(spacerItem4)</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.retranslateUi(Dialog)</span><br><span class="line">        QtCore.QMetaObject.connectSlotsByName(Dialog)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">retranslateUi</span>(<span class="params">self, Dialog</span>):</span><br><span class="line">        _translate = QtCore.QCoreApplication.translate</span><br><span class="line">        Dialog.setWindowTitle(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;查找&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.label.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;查找：&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;确定&quot;</span>))</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.setText(_translate(<span class="string">&quot;Dialog&quot;</span>, <span class="string">&quot;取消&quot;</span>))</span><br><span class="line"></span><br><span class="line">        <span class="variable language_">self</span>.lineEdit.setText(<span class="variable language_">self</span>.search_str)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton.clicked.connect(<span class="variable language_">self</span>.search_app)</span><br><span class="line">        <span class="variable language_">self</span>.pushButton_2.clicked.connect(<span class="variable language_">self</span>.cancel_search)</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">search_app</span>(<span class="params">self</span>):</span><br><span class="line">        <span class="variable language_">self</span>.closeWindow.emit(<span class="variable language_">self</span>.lineEdit.text())</span><br><span class="line">        <span class="variable language_">self</span>.close()</span><br><span class="line"></span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">cancel_search</span>(<span class="params">self</span>):</span><br><span class="line">        <span class="variable language_">self</span>.closeWindow.emit(<span class="string">&#x27;&#x27;</span>)</span><br><span class="line">        <span class="variable language_">self</span>.close()</span><br></pre></td></tr></table></figure>

</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta"><i class="fas fa-circle-user fa-fw"></i>文章作者: </span><span class="post-copyright-info"><a href="https://veryXing.github.io">xing</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta"><i class="fas fa-square-arrow-up-right fa-fw"></i>文章链接: </span><span class="post-copyright-info"><a href="https://veryxing.github.io/article/32b656da.html">https://veryxing.github.io/article/32b656da.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta"><i class="fas fa-circle-exclamation fa-fw"></i>版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来源 <a href="https://veryXing.github.io" target="_blank">Xing's Blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/PyQt/">PyQt</a></div><div class="post-share"><div class="social-share" data-image="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-2.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><a class="prev-post pull-left" href="/article/140ab620.html" title="某网站自动下载音乐mp3和歌词"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-6.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">某网站自动下载音乐mp3和歌词</div></div></a><a class="next-post pull-right" href="/article/a0a0fd82.html" title="PyQt5实现桌面小宠物"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-9.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">PyQt5实现桌面小宠物</div></div></a></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><a href="/article/2241662d.html" title="PyQt5窗口跟随其它窗口"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-3.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2018-10-23</div><div class="title">PyQt5窗口跟随其它窗口</div></div></a><a href="/article/f305b1cc.html" title="PyQt属性动画(QPropertyAnimation)"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-4.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-05-08</div><div class="title">PyQt属性动画(QPropertyAnimation)</div></div></a><a href="/article/bf8fd827.html" title="QSS (Qt Style Sheet) 样式设定"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-6.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-10-14</div><div class="title">QSS (Qt Style Sheet) 样式设定</div></div></a><a href="/article/5a4e93df.html" title="PyQt5动画边框阴影"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-6.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2018-09-25</div><div class="title">PyQt5动画边框阴影</div></div></a><a href="/article/3217c859.html" title="三种方式绑定信号槽"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-10.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2019-05-04</div><div class="title">三种方式绑定信号槽</div></div></a><a href="/article/729610ce.html" title="PyQt5圆形图片"><img class="cover" src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-1.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2018-09-25</div><div class="title">PyQt5圆形图片</div></div></a></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info is-center"><div class="avatar-img"><img src= "/images/2.gif" data-lazy-src="/img/butterfly-icon.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info-name">xing</div><div class="author-info-description"></div><div class="site-data"><a href="/archives/"><div class="headline">文章</div><div class="length-num">59</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">55</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/veryXing"><i class="fab fa-github"></i><span>Follow Me</span></a></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/article/18647ffa.html" title="pytest-qt 测试模态窗体."><img src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-9.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="pytest-qt 测试模态窗体."/></a><div class="content"><a class="title" href="/article/18647ffa.html" title="pytest-qt 测试模态窗体.">pytest-qt 测试模态窗体.</a><time datetime="2024-11-27T17:01:35.284Z" title="发表于 2024-11-28 01:01:35">2024-11-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/article/5a8a6c8d.html" title="post"><img src= "/images/2.gif" data-lazy-src="http://up.36992.com/pic/e6/c5/51/e6c551e768092c8655292d89a4034a74.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="post"/></a><div class="content"><a class="title" href="/article/5a8a6c8d.html" title="post">post</a><time datetime="2024-10-31T15:27:17.000Z" title="发表于 2024-10-31 23:27:17">2024-10-31</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/article/140ab620.html" title="某网站自动下载音乐mp3和歌词"><img src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-6.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="某网站自动下载音乐mp3和歌词"/></a><div class="content"><a class="title" href="/article/140ab620.html" title="某网站自动下载音乐mp3和歌词">某网站自动下载音乐mp3和歌词</a><time datetime="2024-10-31T12:15:16.000Z" title="发表于 2024-10-31 20:15:16">2024-10-31</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/article/32b656da.html" title="PyQt密码管理系统"><img src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-2.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="PyQt密码管理系统"/></a><div class="content"><a class="title" href="/article/32b656da.html" title="PyQt密码管理系统">PyQt密码管理系统</a><time datetime="2024-10-20T14:36:18.000Z" title="发表于 2024-10-20 22:36:18">2024-10-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/article/a0a0fd82.html" title="PyQt5实现桌面小宠物"><img src= "/images/2.gif" data-lazy-src="https://jsd.012700.xyz/gh/jerryc127/CDN/img/material-9.png" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="PyQt5实现桌面小宠物"/></a><div class="content"><a class="title" href="/article/a0a0fd82.html" title="PyQt5实现桌面小宠物">PyQt5实现桌面小宠物</a><time datetime="2024-10-20T14:28:05.000Z" title="发表于 2024-10-20 22:28:05">2024-10-20</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2019 - 2024 By xing</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="日间和夜间模式切换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><div class="js-pjax"></div><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="true" data-click="false"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>(() => {
  const pjaxSelectors = ["head > title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax"]

  window.pjax = new Pjax({
    elements: 'a:not([target="_blank"])',
    selectors: pjaxSelectors,
    cacheBust: false,
    analytics: false,
    scrollRestoration: false
  })

  const triggerPjaxFn = (val) => {
    if (!val) return
    Object.values(val).forEach(fn => fn())
  }

  document.addEventListener('pjax:send', () => {
    // removeEventListener
    btf.removeGlobalFnEvent('pjaxSendOnce')
    btf.removeGlobalFnEvent('themeChange')

    // reset readmode
    const $bodyClassList = document.body.classList
    if ($bodyClassList.contains('read-mode')) $bodyClassList.remove('read-mode')

    triggerPjaxFn(window.globalFn.pjaxSend)
  })

  document.addEventListener('pjax:complete', () => {
    btf.removeGlobalFnEvent('pjaxCompleteOnce')
    document.querySelectorAll('script[data-pjax]').forEach(item => {
      const newScript = document.createElement('script')
      const content = item.text || item.textContent || item.innerHTML || ""
      Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
      newScript.appendChild(document.createTextNode(content))
      item.parentNode.replaceChild(newScript, item)
    })

    triggerPjaxFn(window.globalFn.pjaxComplete)
  })

  document.addEventListener('pjax:error', e => {
    if (e.request.status === 404) {
      pjax.loadUrl('/404.html')
    }
  })
})()</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div><div id="local-search-stats-wrap"></div></div></div><div id="search-mask"></div><script src="/js/search/local-search.js"></script></div></div></body></html>